package com.lulin.mall.cart.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 线程池处理
 *
 * @author lulin
 * @date 2022/12/5 16:07
 */
@Configuration
public class ThreadPoolConfig {
    /**
     * 创建一个线程池
     */
    @Bean
    public ThreadPoolExecutor threadPoolExecutor() {
        return new ThreadPoolExecutor(20
                , 200
                , 10
                , TimeUnit.SECONDS
                , new LinkedBlockingQueue(10000)
                , Executors.defaultThreadFactory()
                //拒绝策略
                , new ThreadPoolExecutor.AbortPolicy()
        );
    }
}
